#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int k;
int quick_sort(int l, int r)
{
	if (l >= r) {
		return arr[l];
	}
	int mid = l + r >> 1;
	int x = arr[mid];
	int i = l - 1;
	int j = r + 1;
	while (i < j) {
		do {
			i++;
		} while (arr[i] < x);
		do {
			j--;
		} while (arr[j] > x);
		if (i < j) {	
			swap(arr[i], arr[j]);
		}
	}
	if (k <= j) {
		quick_sort(l, j);
	}
	else {
		quick_sort(j + 1, r);
	}
}
int main()
{
	int n;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	int ret = quick_sort(1, n);
	cout << ret << endl;
	return 0;
}